package cn.zhang.reimbursement_1.controller;

import cn.zhang.reimbursement_1.model.Type;
import cn.zhang.reimbursement_1.service.TypeService;
import cn.zhang.reimbursement_1.tools.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/type")
@Api(tags = "报销类型模块")
public class TypeController {
    @Autowired
    private TypeService typeService;

    @ApiOperation("添加报销类型")
    @PostMapping("/save_type")
    public JsonData saveType(@RequestBody Type type){
        JsonData jsonData = typeService.saveType(type);
        return jsonData;
    }

    @ApiOperation("查询报销类型")
    @GetMapping("/get_type")
    public JsonData getType(){
        JsonData jsonData = typeService.getType();
        return jsonData;
    }



    @ApiOperation("修改报销类型")
    @PutMapping("/update_type")
    public JsonData updateType(@RequestBody Type type){
        JsonData jsonData = typeService.updateType(type);
        return jsonData;
    }

    @ApiOperation("删除报销类型")
    @DeleteMapping("/del_type")
    public JsonData delType(@RequestParam Integer delId){
        JsonData jsonData = typeService.delType(delId);
        return jsonData;
    }
}
